
<style type="text/css">

.flag{
	color:red;
}

</style>

<div class="main" style="background-color: white;">
	<form id="addForm_edit" enctype="multipart/form-data">
		<input type="hidden" value="${member.member_id}" name="member_id" class="member_id">
		<input type="hidden" value="${member.picture}" name="picture">
		<input type="hidden" value="${member.web_lvid}" name="web_lvid">
		<input type="hidden" value="${member.point}" name="point">
		<input type="hidden" value="${member.publish}" name="publish">
		<input type="hidden" value="${member.sign_in}" name="sign_id">
		<input type="hidden" value="${member.create_time}" name="create_time">
		<input type="hidden" value="${member.password}" name="password">
		<table width="98%" border="0" cellspacing="0" cellpadding="8">
			<tr>
				<th><span class="flag">*</span>用户名：</th>
				<td>
					<input class="input_text student_number" type="text" value="${member.student_number!''}" name="student_number" maxlength="10"></input>
					<span class="number_msg" style="color:red;display: none;"></span>
              		<span class="number_success" style="color:green;display: none;"></span>
				</td>
				<th><span class="flag">*</span>密码：</th>
				<td><input class="input_text easyui-validatebox password" minlength="6" maxlength="12"
					type="password" name="newpassword" data-options="required:true,validType:'minLength[6]'" placeholder="不修改则不填！"></input>
					<span class="password_msg" style="color:red;display: none;"></span>
				</td>
			</tr>
			<tr>
				<th><span class="flag">*</span>昵称：</th>
				<td><input class="input_text nick_name" type="text" name="nick_name" value="${member.nick_name!''}" maxlength="20"></input>
				<span class="nick_name_msg" style="color:red;display: none;"></span>
              	<span class="nick_success" style="color:green;display: none;"></span>
				</td>
				<th>性别：</th>
				<td valign="middle"><select class="easyui-validatebox"
					name="sex">
						<#if member.sex??>
							<#if member.sex==1>
								<option value="1" selected="selected">&nbsp;男&nbsp;</option>
								<option value="0">&nbsp;女&nbsp;</option>
								<#else>
									<option value="1">&nbsp;男&nbsp;</option>
									<option value="0" selected="selected">&nbsp;女&nbsp;</option>
							</#if>
							<#else>
								<option value="1" selected="selected">&nbsp;男&nbsp;</option>
								<option value="0">&nbsp;女&nbsp;</option>
						</#if>
				</select></td>
			</tr>
			<tr>
				<th><span class="flag">*</span>真实姓名：</th>
				<td>
					<input class="input_text real_name" type="text" value="${member.real_name!''}" name="real_name" maxlength="20"></input>
					<span class="real_name_msg" style="color:red;display: none;"></span>
				</td>
				<th>qq：</th>
				<td>
					<input class="input_text" type="text" value="${member.qq!''}" name="qq" maxlength="11"></input>
				</td>
			</tr>
			<tr>
				<th>班级：</th>
				<td>
					<input class="input_text" type="text" value="${member.student_class!''}" name="student_class"></input>
				</td>
				<th>移动电话：</th>
				<td><input class="input_text easyui-validatebox phone" type="text"
					id="name" validType="mobile" value="${member.phone!''}" name="phone"
					data-options="required:false"  onkeyup="this.value=this.value.replace(/\D/g,'')"  onafterpaste="this.value=this.value.replace(/\D/g,'')" maxlength="11"></input>
					<span class="phone_msg" style="color:red;display: none;"></span>
					<span class="phone_success" style="color:green;display: none;"></span>
				</td>
			</tr>
			
		
			<tr>
				<th>安全问题：</th>
				<td><input class="input_text" type="text" id="name"
					name="pw_question" data-options="required:true"
					value="${member.pw_question!''}" maxlength="58"></input>
				</td>
				<th>回答：</th>
				<td><input class="input_text" type="text" id="name"
					name="pw_answer" maxlength="58" value="${member.pw_answer!''}" data-options="required:true,validType:'maxLength[58]"></input></td>
			</tr>
			
			<tr>
				<th>地址：</th>
				<td>
					省
					<select class="easyui-validatebox province_id" name="province_id">
						<option value="0">请选择省份</option>
						<#list provinces as province>
							<#if province.id==0>
								<#else>
								<#if province.id==member.province_id!0>
									<option value="${province.id}" selected="selected">${province.name}</option>
									<#else>
										<option value="${province.id}">${province.name}</option>
								</#if>
							</#if>
						</#list>
					</select>
					&nbsp;&nbsp;
					市
					<select class="easyui-validatebox city_id" name="city_id">
						<#if citys??>
							<#list citys as city>
								<#if city_index==0>
									<option value="0">请选择城市</option>
								</#if>
								<#if city.id==member.city_id!0>
									<option value="${city.id}" selected="selected">${city.name}</option>
									<#else>
										<option value="${city.id}">${city.name}</option>
								</#if>
							</#list>
						</#if>
					</select>
					&nbsp;&nbsp;
					区
					<select class="easyui-validatebox region_id" name="region_id">
						<#if regions??>
							<#list regions as region>
								<#if region_index==0>
									<option value="0">请选择地区</option>
								</#if>
								<#if region.id==member.region_id!0>
									<option value="${region.id}" selected="selected">${region.name}</option>
									<#else>
										<option value="${region.id}">${region.name}</option>
								</#if>
							</#list>
						</#if>
					</select>
				</td>
				<th>是否激活：</th>
				<td>
					<select name="is_activation">
						<#if member.is_activation==0>
							<option value="0" selected="selected">否</option>
							<option value="1">是</option>
							<#else>
								<option value="0">否</option>
								<option value="1" selected="selected">是</option>
						</#if>
					</select>
				</td>
			</tr>
			
			<tr>
				<#if member.is_system??>
					<th>是否是内部人：</th>
					<td>
						<select name="is_system">
							<#if member.is_system==0>
								<option value="0" selected="selected">否</option>
								<option value="1">是</option>
								<#else>
									<option value="0">否</option>
									<option value="1" selected="selected">是</option>
							</#if>
						</select>
					</td>
				</#if>
				
				<th>头像：</th>
				<td>
					<@image border="0" src="${member.picture}" width="100" height="100" style="border-radius:90px;"/>
					<input type="file" name="pic">
				</td>
			</tr>
			
			<tr>
				<th>生日：</th>
				<td>
					<input class="easyui-datebox" style="width: 90px;height: 28px;" id="birthday" name="strBirthday" value="<#if member.birthday??><@dateformat time='${member.birthday}' pattern='yyyy-MM-dd'/></#if>" />
				</td>
				
				<th></th>
				<td></td>
			</tr>
		</table>
		
	<div style="border:0px solid #000000;width:100%;">
		<a href='javascript:void(0)' style="margin-left:45%;" class='button blueButton save'>保存</a>
		
	</div>

	</form>


</div>



<script type="text/javascript">
	




$(".province_id").change(function(){
	var id=$(".province_id").val();
	
	if(id==null){
		$("body").overhang({
			type: "error",
			message: "请选择省份"
		});
		return null;
	}
	
	$.ajax({
		url:"${ctx}/core/admin/address/get-parent.do",
		data: {'pid':id},
		type:"POST",
		dataType:"json",
		success:function(result){
			var data=result.data;
			var length=data.length;
			$(".city_id").empty();
			$(".region_id").empty();
			$(".city_id").append("<option value='0'>请选择城市</option>")
			for(var i=0;i<length;i++){
				$(".city_id").append("<option value='"+data[i].id+"'>"+data[i].name+"</option>");
			}
		},
		error:function(){
			$("body").overhang({
				type: "error",
				message: "请求错误！"
			});
			location.reload(); 
		}
	});
	
});


$(".city_id").change(function(){
	var id=$(".city_id").val();
	
	if(id==null){
		$("body").overhang({
			type: "error",
			message: "请选择城市"
		});
		return null;
	}
	$.ajax({
		url:"${ctx}/core/admin/address/get-area.do",
		data: {'pid':id},
		type:"POST",
		dataType:"json",
		success:function(result){
			var data=result.data;
			var length=data.length;
			$(".region_id").empty();
			for(var i=0;i<length;i++){
				$(".region_id").append("<option value='"+data[i].id+"'>"+data[i].name+"</option>");
			}
		},
		error:function(){
			$("body").overhang({
				type: "error",
				message: "请求错误！"
			});
			location.reload(); 
		}
	});
	
});


//修改
$(".save").click(function(){
	var student_number=$(".student_number").val();
	var password=$(".password").val();
	var nick_name=$(".nick_name").val();
	var real_name=$(".real_name").val();

	//学号验证
	if(student_number==null){ 
		$("body").overhang({
			type: "error",
			message: "学号没有填写！"
		});
		return false;
	}
	if(student_number==""){
		$("body").overhang({
			type: "error",
			message: "学号没有填写！"
		});
		return false;
	}
	student_number=student_number.toUpperCase();
	var flag=student_number.indexOf("P1");
	if(flag==-1){
		$("body").overhang({
			type: "error",
			message: "学号填写错误！"
		});
		return false;
	}
	var len=student_number.length;
	if(len!=10){
		$("body").overhang({
			type: "error",
			message: "学号填写错误！"
		});
		return false;
	}
	

	//昵称
	if(nick_name==null){
		$("body").overhang({
			type: "error",
			message: "昵称没有填写！"
		});
		return false;
	}
	if(nick_name==""){
		$("body").overhang({
			type: "error",
			message: "昵称没有填写！"
		});
		return false;
	}

	//真实姓名
	if(real_name==null){
		$("body").overhang({
			type: "error",
			message: "真实姓名没有填写！"
		});
		return false;
	}
	if(real_name==""){
		$("body").overhang({
			type: "error",
			message: "真实姓名没有填写！"
		});
		return false;
	}



	var options = {
		url : ctx+"/core/admin/member/edit-save.do",
		type : "POST",
		dataType : 'json',
		success : function(result) {
		 	if(result.result==1){
		 		alert(result.message);
		 		location.reload();
		 		
		 		
		 		
		 	}else if(result.result==0){
		 		$("body").overhang({
					type: "error",
					message: result.message
				});
		 		
		 	}
		},
		error : function(e) {
			$("body").overhang({
	 			type: "error",
	 			message: "请求错误！请重试！"
	 		});
			
			
		}
	};
	
	$("#addForm_edit").ajaxSubmit(options); 
		
});



$(".student_number").change(function(){
	var student_number=$(".student_number").val();

	if(student_number==null || student_number==""){
		$(".number_msg").css("display","block");
		$(".number_msg").text("学号没有填写！");
		return null;
	}
	
	student_number=student_number.toUpperCase();
	var flag=student_number.indexOf("P1");
	if(flag==-1){
		$(".number_msg").css("display","block");
		$(".number_msg").text("学号填写错误！");
		return null;
	}
	var len=student_number.length;
	if(len!=10){
		$(".number_msg").css("display","block");
		$(".number_msg").text("学号填写错误！");
		return null;
	}

	$(".number_msg").css("display","none");
	
	var member_id=$(".member_id").val();
	var da={'student_number':student_number,'member_id':member_id};
	//检测学号是否可以注册
	$.ajax({
		url: ctx+"/api/member/check-student_number.do",
		data: da,
		type:"POST",
		dataType:"json",
		success:function(result){
			if(result.result==1){
				$(".number_success").css("display","block");
				$(".number_success").text(result.message);
			}else{
				$(".number_success").css("display","none");
				$(".number_msg").css("display","block");
				$(".number_msg").text(result.message);
			}
		},
		error:function(){
			$("body").overhang({
	 			type: "error",
	 			message: "请求错误！请重试！"
	 		});
		}
	});
	
});

$(".password").blur(function(){
	var password=$(".password").val();
	
	if(password==null || password==""){
		$(".password_msg").css("display","block");
		$(".password_msg").text("密码没有填写！");
		return null;
	}else{
		$(".password_msg").css("display","none");
	}

	len=password.length;
	if(len<6 || len>12){
		$(".password_msg").css("display","block");
		$(".password_msg").text("密码填写错误！");
		return null;
	}

	$(".password_msg").css("display","none");
	
});


$(".real_name").blur(function(){
	var real_name=$(".real_name").val();

	if(real_name==null || real_name==""){
		$(".real_name_msg").css("display","block");
		$(".real_name_msg").text("姓名没有填写！");
		return null;
	}

	$(".real_name_msg").css("display","none");

});

$(".nick_name").change(function(){
	var nick_name=$(".nick_name").val();

	if(nick_name==null || nick_name==""){
		$(".nick_name_msg").css("display","block");
		$(".nick_name_msg").text("昵称没有填写！");
		return null;
	}

	$(".nick_name_msg").css("display","none");
	
	var member_id=$(".member_id").val();
	var da={'nick_name':nick_name,'member_id':member_id};
	//检测昵称是否可以注册
	$.ajax({
		url: ctx+"/api/member/check-nick_name.do",
		data: da,
		type:"POST",
		dataType:"json",
		success:function(result){
			if(result.result==1){
				$(".nick_success").css("display","block");
				$(".nick_success").text(result.message);
			}else{
				$(".nick_success").css("display","none");
				$(".nick_name_msg").css("display","block");
				$(".nick_name_msg").text(result.message);
			}
		},
		error:function(){
			$("body").overhang({
	 			type: "error",
	 			message: "请求错误！请重试！"
	 		});
		}
	});
});

$(".phone").blur(function(){
	var tel=$(".phone").val();
	var reg = /^0?1[3|4|5|8][0-9]\d{8}$/;
	if (reg.test(tel)) {
		$(".phone_msg").css("display","none");
		$(".phone_success").css("display","block");
	  	$(".phone_msg").text("手机号码正确！");
	}else{
		$(".phone_msg").css("display","block");
		$(".phone_success").css("display","none");
	  	$(".phone_msg").text("手机号码错误！");
	}
});


</script>





